<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Math::BigRat - Arbitrary big rational numbers - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Math::BigRat">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Math::BigRat.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Math::BigRat">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Math::BigRat">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Math::BigRat">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Math::BigRat">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Math::BigRat">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Math::BigRat">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Math::BigRat">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Math::BigRat">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Math::BigRat">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Math::BigRat">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Math::BigRat">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Math::BigRat">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Math::BigRat">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Math::BigRat">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Math::BigRat">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Math::BigRat">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Math::BigRat">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Math::BigRat">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Math::BigRat">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Math::BigRat">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Math::BigRat">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Math::BigRat">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Math::BigRat">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Math::BigRat">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Math::BigRat">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Math::BigRat">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Math::BigRat">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Math::BigRat">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Math::BigRat">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Math::BigRat">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Math::BigRat">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Math::BigRat">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Math::BigRat">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Math::BigRat">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Math::BigRat">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Math::BigRat">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Math::BigRat">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Math::BigRat">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Math::BigRat">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Math::BigRat">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Math::BigRat">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Math::BigRat">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Math::BigRat">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Math::BigRat">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Math::BigRat">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Math::BigRat">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Math::BigRat">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Math::BigRat">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Math::BigRat">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Math::BigRat">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Math::BigRat">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Math::BigRat">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Math::BigRat">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Math::BigRat">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Math::BigRat">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Math::BigRat">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Math::BigRat">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Math::BigRat">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Math::BigRat">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Math::BigRat">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Math::BigRat">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Math::BigRat">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Math::BigRat">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Math::BigRat">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Math::BigRat">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Math::BigRat">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Math::BigRat">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Math::BigRat">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Math::BigRat">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Math::BigRat">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Math::BigRat">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Math::BigRat">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Math::BigRat">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Math::BigRat">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Math::BigRat">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Math::BigRat">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Math::BigRat">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Math::BigRat">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Math::BigRat">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Math::BigRat">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Math::BigRat.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Math::BigRat">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Math::BigRat">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Math::BigRat">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Math::BigRat">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Math::BigRat">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Math::BigRat">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Math::BigRat">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Math::BigRat">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Math::BigRat">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Math::BigRat">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Math::BigRat">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Math::BigRat">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Math::BigRat">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Math::BigRat">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Math::BigRat">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Math::BigRat">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Math::BigRat">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Math::BigRat">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Math::BigRat">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Math::BigRat">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Math::BigRat">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Math::BigRat">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Math::BigRat">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Math::BigRat">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Math::BigRat">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Math::BigRat">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Math::BigRat">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Math::BigRat">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Math::BigRat">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Math::BigRat">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Math::BigRat">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Math::BigRat">5.35.1</a>
          <a class="dropdown-item active" href="./Math::BigRat.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Math::BigRat.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Math::BigRat.html">Math::BigRat</a>
          <div id="more">
            (<a href="./Math::BigRat.txt">source</a>,
            <a href="https://metacpan.org/pod/Math::BigRat">CPAN</a>)
          </div>
            <div id="moduleversion">version 0.2614</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#MATH-LIBRARY">MATH LIBRARY</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#METHODS">METHODS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#BUGS">BUGS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#SUPPORT">SUPPORT</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#LICENSE">LICENSE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Math::BigRat.html#AUTHORS">AUTHORS</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Math::BigRat.html#NAME">#</a>NAME</h1>

<p>Math::BigRat - Arbitrary big rational numbers</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Math::BigRat.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code>use Math::BigRat;

my $x = Math::BigRat-&gt;new(&#39;3/7&#39;); $x += &#39;5/9&#39;;

print $x-&gt;bstr(), &quot;\n&quot;;
print $x ** 2, &quot;\n&quot;;

my $y = Math::BigRat-&gt;new(&#39;inf&#39;);
print &quot;$y &quot;, ($y-&gt;is_inf ? &#39;is&#39; : &#39;is not&#39;), &quot; infinity\n&quot;;

my $z = Math::BigRat-&gt;new(144); $z-&gt;bsqrt();</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="./Math::BigRat.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>Math::BigRat complements Math::BigInt and Math::BigFloat by providing support for arbitrary big rational numbers.</p>

<h2 id="MATH-LIBRARY"><a class="permalink" href="./Math::BigRat.html#MATH-LIBRARY">#</a><a id="MATH"></a>MATH LIBRARY</h2>

<p>You can change the underlying module that does the low-level math operations by using:</p>

<pre><code>use Math::BigRat try =&gt; &#39;GMP&#39;;</code></pre>

<p>Note: This needs Math::BigInt::GMP installed.</p>

<p>The following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and when this also fails, revert to Math::BigInt::Calc:</p>

<pre><code>use Math::BigRat try =&gt; &#39;Foo,Math::BigInt::Bar&#39;;</code></pre>

<p>If you want to get warned when the fallback occurs, replace &quot;try&quot; with &quot;lib&quot;:</p>

<pre><code>use Math::BigRat lib =&gt; &#39;Foo,Math::BigInt::Bar&#39;;</code></pre>

<p>If you want the code to die instead, replace &quot;try&quot; with &quot;only&quot;:</p>

<pre><code>use Math::BigRat only =&gt; &#39;Foo,Math::BigInt::Bar&#39;;</code></pre>

<h1 id="METHODS"><a class="permalink" href="./Math::BigRat.html#METHODS">#</a>METHODS</h1>

<p>Any methods not listed here are derived from Math::BigFloat (or Math::BigInt), so make sure you check these two modules for further information.</p>

<dl>

<dt id="new()"><a class="permalink" href="./Math::BigRat.html#new()">#</a><a id="new"></a>new()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;1/3&#39;);</code></pre>

<p>Create a new Math::BigRat object. Input can come in various forms:</p>

<pre><code>$x = Math::BigRat-&gt;new(123);                            # scalars
$x = Math::BigRat-&gt;new(&#39;inf&#39;);                          # infinity
$x = Math::BigRat-&gt;new(&#39;123.3&#39;);                        # float
$x = Math::BigRat-&gt;new(&#39;1/3&#39;);                          # simple string
$x = Math::BigRat-&gt;new(&#39;1 / 3&#39;);                        # spaced
$x = Math::BigRat-&gt;new(&#39;1 / 0.1&#39;);                      # w/ floats
$x = Math::BigRat-&gt;new(Math::BigInt-&gt;new(3));           # BigInt
$x = Math::BigRat-&gt;new(Math::BigFloat-&gt;new(&#39;3.1&#39;));     # BigFloat
$x = Math::BigRat-&gt;new(Math::BigInt::Lite-&gt;new(&#39;2&#39;));   # BigLite

# You can also give D and N as different objects:
$x = Math::BigRat-&gt;new(
        Math::BigInt-&gt;new(-123),
        Math::BigInt-&gt;new(7),
     );                      # =&gt; -123/7</code></pre>

</dd>
<dt id="numerator()"><a class="permalink" href="./Math::BigRat.html#numerator()">#</a><a id="numerator"></a>numerator()</dt>
<dd>

<pre><code>$n = $x-&gt;numerator();</code></pre>

<p>Returns a copy of the numerator (the part above the line) as signed BigInt.</p>

</dd>
<dt id="denominator()"><a class="permalink" href="./Math::BigRat.html#denominator()">#</a><a id="denominator"></a>denominator()</dt>
<dd>

<pre><code>$d = $x-&gt;denominator();</code></pre>

<p>Returns a copy of the denominator (the part under the line) as positive BigInt.</p>

</dd>
<dt id="parts()"><a class="permalink" href="./Math::BigRat.html#parts()">#</a><a id="parts"></a>parts()</dt>
<dd>

<pre><code>($n, $d) = $x-&gt;parts();</code></pre>

<p>Return a list consisting of (signed) numerator and (unsigned) denominator as BigInts.</p>

</dd>
<dt id="numify()"><a class="permalink" href="./Math::BigRat.html#numify()">#</a><a id="numify"></a>numify()</dt>
<dd>

<pre><code>my $y = $x-&gt;numify();</code></pre>

<p>Returns the object as a scalar. This will lose some data if the object cannot be represented by a normal Perl scalar (integer or float), so use <a href="./Math::BigRat.html#as_int%28%29">&quot;as_int()&quot;</a> or <a href="./Math::BigRat.html#as_float%28%29">&quot;as_float()&quot;</a> instead.</p>

<p>This routine is automatically used whenever a scalar is required:</p>

<pre><code>my $x = Math::BigRat-&gt;new(&#39;3/1&#39;);
@array = (0, 1, 2, 3);
$y = $array[$x];                # set $y to 3</code></pre>

</dd>
<dt id="as_int()"><a class="permalink" href="./Math::BigRat.html#as_int()">#</a><a id="as_int"></a>as_int()</dt>
<dd>

</dd>
<dt id="as_number()"><a class="permalink" href="./Math::BigRat.html#as_number()">#</a><a id="as_number"></a>as_number()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;13/7&#39;);
print $x-&gt;as_int(), &quot;\n&quot;;               # &#39;1&#39;</code></pre>

<p>Returns a copy of the object as BigInt, truncated to an integer.</p>

<p><code>as_number()</code> is an alias for <code>as_int()</code>.</p>

</dd>
<dt id="as_float()"><a class="permalink" href="./Math::BigRat.html#as_float()">#</a><a id="as_float"></a>as_float()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;13/7&#39;);
print $x-&gt;as_float(), &quot;\n&quot;;             # &#39;1&#39;

$x = Math::BigRat-&gt;new(&#39;2/3&#39;);
print $x-&gt;as_float(5), &quot;\n&quot;;            # &#39;0.66667&#39;</code></pre>

<p>Returns a copy of the object as BigFloat, preserving the accuracy as wanted, or the default of 40 digits.</p>

<p>This method was added in v0.22 of Math::BigRat (April 2008).</p>

</dd>
<dt id="as_hex()"><a class="permalink" href="./Math::BigRat.html#as_hex()">#</a><a id="as_hex"></a>as_hex()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;13&#39;);
print $x-&gt;as_hex(), &quot;\n&quot;;               # &#39;0xd&#39;</code></pre>

<p>Returns the BigRat as hexadecimal string. Works only for integers.</p>

</dd>
<dt id="as_bin()"><a class="permalink" href="./Math::BigRat.html#as_bin()">#</a><a id="as_bin"></a>as_bin()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;13&#39;);
print $x-&gt;as_bin(), &quot;\n&quot;;               # &#39;0x1101&#39;</code></pre>

<p>Returns the BigRat as binary string. Works only for integers.</p>

</dd>
<dt id="as_oct()"><a class="permalink" href="./Math::BigRat.html#as_oct()">#</a><a id="as_oct"></a>as_oct()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;new(&#39;13&#39;);
print $x-&gt;as_oct(), &quot;\n&quot;;               # &#39;015&#39;</code></pre>

<p>Returns the BigRat as octal string. Works only for integers.</p>

</dd>
<dt id="from_hex()"><a class="permalink" href="./Math::BigRat.html#from_hex()">#</a><a id="from_hex"></a>from_hex()</dt>
<dd>

<pre><code>my $h = Math::BigRat-&gt;from_hex(&#39;0x10&#39;);</code></pre>

<p>Create a BigRat from a hexadecimal number in string form.</p>

</dd>
<dt id="from_oct()"><a class="permalink" href="./Math::BigRat.html#from_oct()">#</a><a id="from_oct"></a>from_oct()</dt>
<dd>

<pre><code>my $o = Math::BigRat-&gt;from_oct(&#39;020&#39;);</code></pre>

<p>Create a BigRat from an octal number in string form.</p>

</dd>
<dt id="from_bin()"><a class="permalink" href="./Math::BigRat.html#from_bin()">#</a><a id="from_bin"></a>from_bin()</dt>
<dd>

<pre><code>my $b = Math::BigRat-&gt;from_bin(&#39;0b10000000&#39;);</code></pre>

<p>Create a BigRat from an binary number in string form.</p>

</dd>
<dt id="bnan()"><a class="permalink" href="./Math::BigRat.html#bnan()">#</a><a id="bnan"></a>bnan()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;bnan();</code></pre>

<p>Creates a new BigRat object representing NaN (Not A Number). If used on an object, it will set it to NaN:</p>

<pre><code>$x-&gt;bnan();</code></pre>

</dd>
<dt id="bzero()"><a class="permalink" href="./Math::BigRat.html#bzero()">#</a><a id="bzero"></a>bzero()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;bzero();</code></pre>

<p>Creates a new BigRat object representing zero. If used on an object, it will set it to zero:</p>

<pre><code>$x-&gt;bzero();</code></pre>

</dd>
<dt id="binf()"><a class="permalink" href="./Math::BigRat.html#binf()">#</a><a id="binf"></a>binf()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;binf($sign);</code></pre>

<p>Creates a new BigRat object representing infinity. The optional argument is either &#39;-&#39; or &#39;+&#39;, indicating whether you want infinity or minus infinity. If used on an object, it will set it to infinity:</p>

<pre><code>$x-&gt;binf();
$x-&gt;binf(&#39;-&#39;);</code></pre>

</dd>
<dt id="bone()"><a class="permalink" href="./Math::BigRat.html#bone()">#</a><a id="bone"></a>bone()</dt>
<dd>

<pre><code>$x = Math::BigRat-&gt;bone($sign);</code></pre>

<p>Creates a new BigRat object representing one. The optional argument is either &#39;-&#39; or &#39;+&#39;, indicating whether you want one or minus one. If used on an object, it will set it to one:</p>

<pre><code>$x-&gt;bone();                 # +1
$x-&gt;bone(&#39;-&#39;);              # -1</code></pre>

</dd>
<dt id="length()"><a class="permalink" href="./Math::BigRat.html#length()">#</a><a id="length"></a>length()</dt>
<dd>

<pre><code>$len = $x-&gt;length();</code></pre>

<p>Return the length of $x in digits for integer values.</p>

</dd>
<dt id="digit()"><a class="permalink" href="./Math::BigRat.html#digit()">#</a><a id="digit"></a>digit()</dt>
<dd>

<pre><code>print Math::BigRat-&gt;new(&#39;123/1&#39;)-&gt;digit(1);     # 1
print Math::BigRat-&gt;new(&#39;123/1&#39;)-&gt;digit(-1);    # 3</code></pre>

<p>Return the N&#39;ths digit from X when X is an integer value.</p>

</dd>
<dt id="bnorm()"><a class="permalink" href="./Math::BigRat.html#bnorm()">#</a><a id="bnorm"></a>bnorm()</dt>
<dd>

<pre><code>$x-&gt;bnorm();</code></pre>

<p>Reduce the number to the shortest form. This routine is called automatically whenever it is needed.</p>

</dd>
<dt id="bfac()"><a class="permalink" href="./Math::BigRat.html#bfac()">#</a><a id="bfac"></a>bfac()</dt>
<dd>

<pre><code>$x-&gt;bfac();</code></pre>

<p>Calculates the factorial of $x. For instance:</p>

<pre><code>print Math::BigRat-&gt;new(&#39;3/1&#39;)-&gt;bfac(), &quot;\n&quot;;   # 1*2*3
print Math::BigRat-&gt;new(&#39;5/1&#39;)-&gt;bfac(), &quot;\n&quot;;   # 1*2*3*4*5</code></pre>

<p>Works currently only for integers.</p>

</dd>
<dt id="bround()/round()/bfround()"><a class="permalink" href="./Math::BigRat.html#bround()/round()/bfround()">#</a><a id="bround"></a><a id="bround-round-bfround"></a>bround()/round()/bfround()</dt>
<dd>

<p>Are not yet implemented.</p>

</dd>
<dt id="bmod()"><a class="permalink" href="./Math::BigRat.html#bmod()">#</a><a id="bmod"></a>bmod()</dt>
<dd>

<pre><code>$x-&gt;bmod($y);</code></pre>

<p>Returns $x modulo $y. When $x is finite, and $y is finite and non-zero, the result is identical to the remainder after floored division (F-division). If, in addition, both $x and $y are integers, the result is identical to the result from Perl&#39;s % operator.</p>

</dd>
<dt id="bmodinv()"><a class="permalink" href="./Math::BigRat.html#bmodinv()">#</a><a id="bmodinv"></a>bmodinv()</dt>
<dd>

<pre><code>$x-&gt;bmodinv($mod);          # modular multiplicative inverse</code></pre>

<p>Returns the multiplicative inverse of <code>$x</code> modulo <code>$mod</code>. If</p>

<pre><code>$y = $x -&gt; copy() -&gt; bmodinv($mod)</code></pre>

<p>then <code>$y</code> is the number closest to zero, and with the same sign as <code>$mod</code>, satisfying</p>

<pre><code>($x * $y) % $mod = 1 % $mod</code></pre>

<p>If <code>$x</code> and <code>$y</code> are non-zero, they must be relative primes, i.e., <code>bgcd($y, $mod)==1</code>. &#39;<code>NaN</code>&#39; is returned when no modular multiplicative inverse exists.</p>

</dd>
<dt id="bmodpow()"><a class="permalink" href="./Math::BigRat.html#bmodpow()">#</a><a id="bmodpow"></a>bmodpow()</dt>
<dd>

<pre><code>$num-&gt;bmodpow($exp,$mod);           # modular exponentiation
                                    # ($num**$exp % $mod)</code></pre>

<p>Returns the value of <code>$num</code> taken to the power <code>$exp</code> in the modulus <code>$mod</code> using binary exponentiation. <code>bmodpow</code> is far superior to writing</p>

<pre><code>$num ** $exp % $mod</code></pre>

<p>because it is much faster - it reduces internal variables into the modulus whenever possible, so it operates on smaller numbers.</p>

<p><code>bmodpow</code> also supports negative exponents.</p>

<pre><code>bmodpow($num, -1, $mod)</code></pre>

<p>is exactly equivalent to</p>

<pre><code>bmodinv($num, $mod)</code></pre>

</dd>
<dt id="bneg()"><a class="permalink" href="./Math::BigRat.html#bneg()">#</a><a id="bneg"></a>bneg()</dt>
<dd>

<pre><code>$x-&gt;bneg();</code></pre>

<p>Used to negate the object in-place.</p>

</dd>
<dt id="is_one()"><a class="permalink" href="./Math::BigRat.html#is_one()">#</a><a id="is_one"></a>is_one()</dt>
<dd>

<pre><code>print &quot;$x is 1\n&quot; if $x-&gt;is_one();</code></pre>

<p>Return true if $x is exactly one, otherwise false.</p>

</dd>
<dt id="is_zero()"><a class="permalink" href="./Math::BigRat.html#is_zero()">#</a><a id="is_zero"></a>is_zero()</dt>
<dd>

<pre><code>print &quot;$x is 0\n&quot; if $x-&gt;is_zero();</code></pre>

<p>Return true if $x is exactly zero, otherwise false.</p>

</dd>
<dt id="is_pos()/is_positive()"><a class="permalink" href="./Math::BigRat.html#is_pos()/is_positive()">#</a><a id="is_pos"></a><a id="is_pos-is_positive"></a>is_pos()/is_positive()</dt>
<dd>

<pre><code>print &quot;$x is &gt;= 0\n&quot; if $x-&gt;is_positive();</code></pre>

<p>Return true if $x is positive (greater than or equal to zero), otherwise false. Please note that &#39;+inf&#39; is also positive, while &#39;NaN&#39; and &#39;-inf&#39; aren&#39;t.</p>

<p><code>is_positive()</code> is an alias for <code>is_pos()</code>.</p>

</dd>
<dt id="is_neg()/is_negative()"><a class="permalink" href="./Math::BigRat.html#is_neg()/is_negative()">#</a><a id="is_neg"></a><a id="is_neg-is_negative"></a>is_neg()/is_negative()</dt>
<dd>

<pre><code>print &quot;$x is &lt; 0\n&quot; if $x-&gt;is_negative();</code></pre>

<p>Return true if $x is negative (smaller than zero), otherwise false. Please note that &#39;-inf&#39; is also negative, while &#39;NaN&#39; and &#39;+inf&#39; aren&#39;t.</p>

<p><code>is_negative()</code> is an alias for <code>is_neg()</code>.</p>

</dd>
<dt id="is_int()"><a class="permalink" href="./Math::BigRat.html#is_int()">#</a><a id="is_int"></a>is_int()</dt>
<dd>

<pre><code>print &quot;$x is an integer\n&quot; if $x-&gt;is_int();</code></pre>

<p>Return true if $x has a denominator of 1 (e.g. no fraction parts), otherwise false. Please note that &#39;-inf&#39;, &#39;inf&#39; and &#39;NaN&#39; aren&#39;t integer.</p>

</dd>
<dt id="is_odd()"><a class="permalink" href="./Math::BigRat.html#is_odd()">#</a><a id="is_odd"></a>is_odd()</dt>
<dd>

<pre><code>print &quot;$x is odd\n&quot; if $x-&gt;is_odd();</code></pre>

<p>Return true if $x is odd, otherwise false.</p>

</dd>
<dt id="is_even()"><a class="permalink" href="./Math::BigRat.html#is_even()">#</a><a id="is_even"></a>is_even()</dt>
<dd>

<pre><code>print &quot;$x is even\n&quot; if $x-&gt;is_even();</code></pre>

<p>Return true if $x is even, otherwise false.</p>

</dd>
<dt id="bceil()"><a class="permalink" href="./Math::BigRat.html#bceil()">#</a><a id="bceil"></a>bceil()</dt>
<dd>

<pre><code>$x-&gt;bceil();</code></pre>

<p>Set $x to the next bigger integer value (e.g. truncate the number to integer and then increment it by one).</p>

</dd>
<dt id="bfloor()"><a class="permalink" href="./Math::BigRat.html#bfloor()">#</a><a id="bfloor"></a>bfloor()</dt>
<dd>

<pre><code>$x-&gt;bfloor();</code></pre>

<p>Truncate $x to an integer value.</p>

</dd>
<dt id="bint()"><a class="permalink" href="./Math::BigRat.html#bint()">#</a><a id="bint"></a>bint()</dt>
<dd>

<pre><code>$x-&gt;bint();</code></pre>

<p>Round $x towards zero.</p>

</dd>
<dt id="bsqrt()"><a class="permalink" href="./Math::BigRat.html#bsqrt()">#</a><a id="bsqrt"></a>bsqrt()</dt>
<dd>

<pre><code>$x-&gt;bsqrt();</code></pre>

<p>Calculate the square root of $x.</p>

</dd>
<dt id="broot()"><a class="permalink" href="./Math::BigRat.html#broot()">#</a><a id="broot"></a>broot()</dt>
<dd>

<pre><code>$x-&gt;broot($n);</code></pre>

<p>Calculate the N&#39;th root of $x.</p>

</dd>
<dt id="badd()"><a class="permalink" href="./Math::BigRat.html#badd()">#</a><a id="badd"></a>badd()</dt>
<dd>

<pre><code>$x-&gt;badd($y);</code></pre>

<p>Adds $y to $x and returns the result.</p>

</dd>
<dt id="bmul()"><a class="permalink" href="./Math::BigRat.html#bmul()">#</a><a id="bmul"></a>bmul()</dt>
<dd>

<pre><code>$x-&gt;bmul($y);</code></pre>

<p>Multiplies $y to $x and returns the result.</p>

</dd>
<dt id="bsub()"><a class="permalink" href="./Math::BigRat.html#bsub()">#</a><a id="bsub"></a>bsub()</dt>
<dd>

<pre><code>$x-&gt;bsub($y);</code></pre>

<p>Subtracts $y from $x and returns the result.</p>

</dd>
<dt id="bdiv()"><a class="permalink" href="./Math::BigRat.html#bdiv()">#</a><a id="bdiv"></a>bdiv()</dt>
<dd>

<pre><code>$q = $x-&gt;bdiv($y);
($q, $r) = $x-&gt;bdiv($y);</code></pre>

<p>In scalar context, divides $x by $y and returns the result. In list context, does floored division (F-division), returning an integer $q and a remainder $r so that $x = $q * $y + $r. The remainer (modulo) is equal to what is returned by <code>$x-</code>bmod($y)&gt;.</p>

</dd>
<dt id="bdec()"><a class="permalink" href="./Math::BigRat.html#bdec()">#</a><a id="bdec"></a>bdec()</dt>
<dd>

<pre><code>$x-&gt;bdec();</code></pre>

<p>Decrements $x by 1 and returns the result.</p>

</dd>
<dt id="binc()"><a class="permalink" href="./Math::BigRat.html#binc()">#</a><a id="binc"></a>binc()</dt>
<dd>

<pre><code>$x-&gt;binc();</code></pre>

<p>Increments $x by 1 and returns the result.</p>

</dd>
<dt id="copy()"><a class="permalink" href="./Math::BigRat.html#copy()">#</a><a id="copy"></a>copy()</dt>
<dd>

<pre><code>my $z = $x-&gt;copy();</code></pre>

<p>Makes a deep copy of the object.</p>

<p>Please see the documentation in <a href="./Math::BigInt.html">Math::BigInt</a> for further details.</p>

</dd>
<dt id="bstr()/bsstr()"><a class="permalink" href="./Math::BigRat.html#bstr()/bsstr()">#</a><a id="bstr"></a><a id="bstr-bsstr"></a>bstr()/bsstr()</dt>
<dd>

<pre><code>my $x = Math::BigRat-&gt;new(&#39;8/4&#39;);
print $x-&gt;bstr(), &quot;\n&quot;;             # prints 1/2
print $x-&gt;bsstr(), &quot;\n&quot;;            # prints 1/2</code></pre>

<p>Return a string representing this object.</p>

</dd>
<dt id="bcmp()"><a class="permalink" href="./Math::BigRat.html#bcmp()">#</a><a id="bcmp"></a>bcmp()</dt>
<dd>

<pre><code>$x-&gt;bcmp($y);</code></pre>

<p>Compares $x with $y and takes the sign into account. Returns -1, 0, 1 or undef.</p>

</dd>
<dt id="bacmp()"><a class="permalink" href="./Math::BigRat.html#bacmp()">#</a><a id="bacmp"></a>bacmp()</dt>
<dd>

<pre><code>$x-&gt;bacmp($y);</code></pre>

<p>Compares $x with $y while ignoring their sign. Returns -1, 0, 1 or undef.</p>

</dd>
<dt id="beq()"><a class="permalink" href="./Math::BigRat.html#beq()">#</a><a id="beq"></a>beq()</dt>
<dd>

<pre><code>$x -&gt; beq($y);</code></pre>

<p>Returns true if and only if $x is equal to $y, and false otherwise.</p>

</dd>
<dt id="bne()"><a class="permalink" href="./Math::BigRat.html#bne()">#</a><a id="bne"></a>bne()</dt>
<dd>

<pre><code>$x -&gt; bne($y);</code></pre>

<p>Returns true if and only if $x is not equal to $y, and false otherwise.</p>

</dd>
<dt id="blt()"><a class="permalink" href="./Math::BigRat.html#blt()">#</a><a id="blt"></a>blt()</dt>
<dd>

<pre><code>$x -&gt; blt($y);</code></pre>

<p>Returns true if and only if $x is equal to $y, and false otherwise.</p>

</dd>
<dt id="ble()"><a class="permalink" href="./Math::BigRat.html#ble()">#</a><a id="ble"></a>ble()</dt>
<dd>

<pre><code>$x -&gt; ble($y);</code></pre>

<p>Returns true if and only if $x is less than or equal to $y, and false otherwise.</p>

</dd>
<dt id="bgt()"><a class="permalink" href="./Math::BigRat.html#bgt()">#</a><a id="bgt"></a>bgt()</dt>
<dd>

<pre><code>$x -&gt; bgt($y);</code></pre>

<p>Returns true if and only if $x is greater than $y, and false otherwise.</p>

</dd>
<dt id="bge()"><a class="permalink" href="./Math::BigRat.html#bge()">#</a><a id="bge"></a>bge()</dt>
<dd>

<pre><code>$x -&gt; bge($y);</code></pre>

<p>Returns true if and only if $x is greater than or equal to $y, and false otherwise.</p>

</dd>
<dt id="blsft()/brsft()"><a class="permalink" href="./Math::BigRat.html#blsft()/brsft()">#</a><a id="blsft"></a><a id="blsft-brsft"></a>blsft()/brsft()</dt>
<dd>

<p>Used to shift numbers left/right.</p>

<p>Please see the documentation in <a href="./Math::BigInt.html">Math::BigInt</a> for further details.</p>

</dd>
<dt id="band()"><a class="permalink" href="./Math::BigRat.html#band()">#</a><a id="band"></a>band()</dt>
<dd>

<pre><code>$x-&gt;band($y);               # bitwise and</code></pre>

</dd>
<dt id="bior()"><a class="permalink" href="./Math::BigRat.html#bior()">#</a><a id="bior"></a>bior()</dt>
<dd>

<pre><code>$x-&gt;bior($y);               # bitwise inclusive or</code></pre>

</dd>
<dt id="bxor()"><a class="permalink" href="./Math::BigRat.html#bxor()">#</a><a id="bxor"></a>bxor()</dt>
<dd>

<pre><code>$x-&gt;bxor($y);               # bitwise exclusive or</code></pre>

</dd>
<dt id="bnot()"><a class="permalink" href="./Math::BigRat.html#bnot()">#</a><a id="bnot"></a>bnot()</dt>
<dd>

<pre><code>$x-&gt;bnot();                 # bitwise not (two&#39;s complement)</code></pre>

</dd>
<dt id="bpow()"><a class="permalink" href="./Math::BigRat.html#bpow()">#</a><a id="bpow"></a>bpow()</dt>
<dd>

<pre><code>$x-&gt;bpow($y);</code></pre>

<p>Compute $x ** $y.</p>

<p>Please see the documentation in <a href="./Math::BigInt.html">Math::BigInt</a> for further details.</p>

</dd>
<dt id="blog()"><a class="permalink" href="./Math::BigRat.html#blog()">#</a><a id="blog"></a>blog()</dt>
<dd>

<pre><code>$x-&gt;blog($base, $accuracy);         # logarithm of x to the base $base</code></pre>

<p>If <code>$base</code> is not defined, Euler&#39;s number (e) is used:</p>

<pre><code>print $x-&gt;blog(undef, 100);         # log(x) to 100 digits</code></pre>

</dd>
<dt id="bexp()"><a class="permalink" href="./Math::BigRat.html#bexp()">#</a><a id="bexp"></a>bexp()</dt>
<dd>

<pre><code>$x-&gt;bexp($accuracy);        # calculate e ** X</code></pre>

<p>Calculates two integers A and B so that A/B is equal to <code>e ** $x</code>, where <code>e</code> is Euler&#39;s number.</p>

<p>This method was added in v0.20 of Math::BigRat (May 2007).</p>

<p>See also <code>blog()</code>.</p>

</dd>
<dt id="bnok()"><a class="permalink" href="./Math::BigRat.html#bnok()">#</a><a id="bnok"></a>bnok()</dt>
<dd>

<pre><code>$x-&gt;bnok($y);               # x over y (binomial coefficient n over k)</code></pre>

<p>Calculates the binomial coefficient n over k, also called the &quot;choose&quot; function. The result is equivalent to:</p>

<pre><code class="plaintext">( n )      n!
| - |  = -------
( k )    k!(n-k)!</code></pre>

<p>This method was added in v0.20 of Math::BigRat (May 2007).</p>

</dd>
<dt id="config()"><a class="permalink" href="./Math::BigRat.html#config()">#</a><a id="config"></a>config()</dt>
<dd>

<pre><code>Math::BigRat-&gt;config(&quot;trap_nan&quot; =&gt; 1);      # set
$accu = Math::BigRat-&gt;config(&quot;accuracy&quot;);   # get</code></pre>

<p>Set or get configuration parameter values. Read-only parameters are marked as RO. Read-write parameters are marked as RW. The following parameters are supported.</p>

<pre><code class="plaintext">Parameter       RO/RW   Description
                        Example
============================================================
lib             RO      Name of the math backend library
                        Math::BigInt::Calc
lib_version     RO      Version of the math backend library
                        0.30
class           RO      The class of config you just called
                        Math::BigRat
version         RO      version number of the class you used
                        0.10
upgrade         RW      To which class numbers are upgraded
                        undef
downgrade       RW      To which class numbers are downgraded
                        undef
precision       RW      Global precision
                        undef
accuracy        RW      Global accuracy
                        undef
round_mode      RW      Global round mode
                        even
div_scale       RW      Fallback accuracy for div, sqrt etc.
                        40
trap_nan        RW      Trap NaNs
                        undef
trap_inf        RW      Trap +inf/-inf
                        undef</code></pre>

</dd>
</dl>

<h1 id="BUGS"><a class="permalink" href="./Math::BigRat.html#BUGS">#</a>BUGS</h1>

<p>Please report any bugs or feature requests to <code>bug-math-bigrat at rt.cpan.org</code>, or through the web interface at <a href="https://rt.cpan.org/Ticket/Create.html?Queue=Math-BigRat">https://rt.cpan.org/Ticket/Create.html?Queue=Math-BigRat</a> (requires login). We will be notified, and then you&#39;ll automatically be notified of progress on your bug as I make changes.</p>

<h1 id="SUPPORT"><a class="permalink" href="./Math::BigRat.html#SUPPORT">#</a>SUPPORT</h1>

<p>You can find documentation for this module with the perldoc command.</p>

<pre><code class="plaintext">perldoc Math::BigRat</code></pre>

<p>You can also look for information at:</p>

<ul>

<li><p>RT: CPAN&#39;s request tracker</p>

<p><a href="https://rt.cpan.org/Public/Dist/Display.html?Name=Math-BigRat">https://rt.cpan.org/Public/Dist/Display.html?Name=Math-BigRat</a></p>

</li>
<li><p>AnnoCPAN: Annotated CPAN documentation</p>

<p><a href="http://annocpan.org/dist/Math-BigRat">http://annocpan.org/dist/Math-BigRat</a></p>

</li>
<li><p>CPAN Ratings</p>

<p><a href="http://cpanratings.perl.org/dist/Math-BigRat">http://cpanratings.perl.org/dist/Math-BigRat</a></p>

</li>
<li><p>Search CPAN</p>

<p><a href="http://search.cpan.org/dist/Math-BigRat/">http://search.cpan.org/dist/Math-BigRat/</a></p>

</li>
<li><p>CPAN Testers Matrix</p>

<p><a href="http://matrix.cpantesters.org/?dist=Math-BigRat">http://matrix.cpantesters.org/?dist=Math-BigRat</a></p>

</li>
<li><p>The Bignum mailing list</p>

<ul>

<li><p>Post to mailing list</p>

<p><code>bignum at lists.scsys.co.uk</code></p>

</li>
<li><p>View mailing list</p>

<p><a href="http://lists.scsys.co.uk/pipermail/bignum/">http://lists.scsys.co.uk/pipermail/bignum/</a></p>

</li>
<li><p>Subscribe/Unsubscribe</p>

<p><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/bignum">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/bignum</a></p>

</li>
</ul>

</li>
</ul>

<h1 id="LICENSE"><a class="permalink" href="./Math::BigRat.html#LICENSE">#</a>LICENSE</h1>

<p>This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.</p>

<h1 id="SEE-ALSO"><a class="permalink" href="./Math::BigRat.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p><a href="bigrat.html">bigrat</a>, <a href="./Math::BigFloat.html">Math::BigFloat</a> and <a href="./Math::BigInt.html">Math::BigInt</a> as well as the backends <a href="./Math::BigInt::FastCalc.html">Math::BigInt::FastCalc</a>, <a href="./Math::BigInt::GMP.html">Math::BigInt::GMP</a>, and <a href="./Math::BigInt::Pari.html">Math::BigInt::Pari</a>.</p>

<h1 id="AUTHORS"><a class="permalink" href="./Math::BigRat.html#AUTHORS">#</a>AUTHORS</h1>

<ul>

<li><p>Tels <a href="http://bloodgate.com/">http://bloodgate.com/</a> 2001-2009.</p>

</li>
<li><p>Maintained by Peter John Acklam &lt;pjacklam@online.no&gt; 2011-</p>

</li>
</ul>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
